using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;

namespace YouVisio.Silverlight.TextDiffTests.Utils
{
    public class StringBuilderWithState<TState>
    {
        private readonly StringBuilder _builder = new StringBuilder();

        public TState State { get; set; }

        public StringBuilderWithState()
        {
        }
        public StringBuilderWithState(TState state)
        {
            State = state;
        }


        #region Append
        public StringBuilder Append(bool value)
        {
            return this._builder.Append(value);
        }

        public StringBuilder Append(byte value)
        {
            return this._builder.Append(value);
        }

        [SecuritySafeCritical]
        public StringBuilder Append(char value)
        {
            return this._builder.Append(value);
        }

        public StringBuilder Append(decimal value)
        {
            return this._builder.Append(value);
        }

        public StringBuilder Append(double value)
        {
            return this._builder.Append(value);
        }

        public StringBuilder Append(short value)
        {
            return this._builder.Append(value);
        }

        [SecuritySafeCritical]
        public StringBuilder Append(char[] value)
        {
            return this._builder.Append(value);
        }

        public StringBuilder Append(int value)
        {
            return this._builder.Append(value);
        }

        public StringBuilder Append(long value)
        {
            return this._builder.Append(value);
        }

        public StringBuilder Append(object value)
        {
            return this._builder.Append(value);
        }

        [CLSCompliant(false)]
        public StringBuilder Append(sbyte value)
        {
            return this._builder.Append(value);
        }

        public StringBuilder Append(float value)
        {
            return this._builder.Append(value);
        }

        [SecuritySafeCritical]
        public StringBuilder Append(string value)
        {
            return this._builder.Append(value);
        }

        [CLSCompliant(false)]
        public StringBuilder Append(ushort value)
        {
            return this._builder.Append(value);
        }

        [CLSCompliant(false)]
        public StringBuilder Append(uint value)
        {
            return this._builder.Append(value);
        }

        [CLSCompliant(false)]
        public StringBuilder Append(ulong value)
        {
            return this._builder.Append(value);
        }

        [SecuritySafeCritical]
        public StringBuilder Append(char value, int repeatCount)
        {
            return this._builder.Append(value);
        }

        [SecuritySafeCritical]
        public StringBuilder Append(string value, int startIndex, int count)
        {
            return this._builder.Append(value);
        }

        [SecuritySafeCritical]
        public StringBuilder Append(char[] value, int startIndex, int charCount)
        {
            return this._builder.Append(value);
        }
        #endregion

        #region AppendFormat
        public StringBuilder AppendFormat(string format, object arg0)
        {
            return this._builder.AppendFormat(format, arg0);
        }

        public StringBuilder AppendFormat(string format, params object[] args)
        {
            return this._builder.AppendFormat(format, args);
        }

        [SecuritySafeCritical]
        public StringBuilder AppendFormat(IFormatProvider provider, string format, params object[] args)
        {
            return this._builder.AppendFormat(provider, format, args);
        }

        public StringBuilder AppendFormat(string format, object arg0, object arg1)
        {
            return this._builder.AppendFormat(format, arg0, arg1);
        }

        public StringBuilder AppendFormat(string format, object arg0, object arg1, object arg2)
        {
            return this._builder.AppendFormat(format, arg0, arg1, arg2);
        }
        #endregion

        [ComVisible(false)]
        public StringBuilder AppendLine()
        {
            return this._builder.AppendLine();
        }

        [ComVisible(false)]
        public StringBuilder AppendLine(string value)
        {
            return this._builder.AppendLine(value);
        }

        public StringBuilder Clear()
        {
            return this._builder.Clear();
        }

        public int EnsureCapacity(int capacity)
        {
            return this._builder.EnsureCapacity(capacity);
        }

        public bool Equals(StringBuilder sb)
        {
            return this._builder.Equals(sb);
        }

        #region Insert
        public StringBuilder Insert(int index, char[] value)
        {
            return this._builder.Insert(index, value);
        }

        [SecuritySafeCritical]
        public StringBuilder Insert(int index, string value)
        {
            return this._builder.Insert(index, value);
        }

        [SecuritySafeCritical]
        public StringBuilder Insert(int index, string value, int count)
        {
            return this._builder.Insert(index, value, count);
        }

        [SecuritySafeCritical]
        public StringBuilder Insert(int index, char[] value, int startIndex, int charCount)
        {
            return this._builder.Insert(index, value, startIndex, charCount);
        }
        #endregion

        [SecuritySafeCritical]
        public StringBuilder Remove(int startIndex, int length)
        {
            return this._builder.Remove(startIndex, length);
        }

        #region Replace
        public StringBuilder Replace(char oldChar, char newChar)
        {
            return this._builder.Replace(oldChar, newChar);
        }
        [SecuritySafeCritical]
        public StringBuilder Replace(string oldValue, string newValue)
        {
            return this._builder.Replace(oldValue, newValue);
        }
        [SecuritySafeCritical]
        public StringBuilder Replace(char oldChar, char newChar, int startIndex, int count)
        {
            return this._builder.Replace(oldChar, newChar, startIndex, count);
        }
        [SecuritySafeCritical]
        public StringBuilder Replace(string oldValue, string newValue, int startIndex, int count)
        {
            return this._builder.Replace(oldValue, newValue, startIndex, count);
        }
        #endregion

        [SecuritySafeCritical]
        public override string ToString()
        {
            return this._builder.ToString();
        }

        [SecuritySafeCritical]
        public string ToString(int startIndex, int length)
        {
            return this._builder.ToString(startIndex, length);
        }

        [SecuritySafeCritical]
        public string ToStringWithState()
        {
            return "State:[" + State + "] " + this._builder.ToString();
        }

        // Properties
        public int Capacity
        {
            get
            {
                return this._builder.Capacity;
            }
            set
            {
                this._builder.Capacity = value;
            }
        }

        public char this[int index]
        {
            get
            {
                return this._builder[index];
            }
            set
            {
                this._builder[index] = value;
            }
        }

        public int Length
        {
            get
            {
                return this._builder.Length;
            }
            [SecuritySafeCritical]
            set
            {
                this._builder.Length = value;
            }
        }
    }
}